// given an array of ints, return indices of the two numbers suck that they add up to a specific target

#include <iostream>
#include <vector>
using namespace std;

void two_sum(vector<int> nums, int target)
{
  int nums_size = nums.size();
  vector<int> result(2);

  for (int i = 0; i < nums_size - 1; ++i) {
    for (int j = 0; j + 1 < nums_size; ++j) {
      if (nums[i] + nums[j] == target) {
        // save two index
        result[0] = i;
        result[1] = j;
        break;
      }
    }
  }

  cout << result[0] << ' ' << result[1] << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> inputs(n);

  for (int i = 0; i < n; ++i) {
    cin >> inputs[i];
  }

  int target;
  cin >> target;
  two_sum(inputs, target);
  return 0;
}

